import 'package:cbec_app/utils/cache_mgr.dart';

///用户缓存数据
class AppData {
  AppData._();

  /// 获取版本号
  static String get jPushRegistrationID {
    final value = CacheMgr.getString('registrationID') ?? '';
    print('读取 registrationID: $value');
    return value;
  }

  static set jPushRegistrationID(String registrationID) {
    print('设置 registrationID: $registrationID');
    CacheMgr.setString('registrationID', registrationID);
  }

  /// 获取是否是第一次进入app
  static bool get isHaveAgree {
    final value = CacheMgr.getBool('isHaveAgree') ?? false;
    print('读取 isHaveAgree: $value');
    return value;
  }

  static set isHaveAgree(bool boolValue) {
    print('设置 isHaveAgree: $boolValue');
    CacheMgr.setBool('isHaveAgree', boolValue);
    print('isHaveAgree isHaveAgree: ${AppData.isHaveAgree}');
  }

  /// 获取版本号
  static String get versionNo {
    final value = CacheMgr.getString('versionNo') ?? '';
    print('读取 版本号: $value');
    return value;
  }

  static set versionNo(String versionNo) {
    print('设置 版本号: $versionNo');
    CacheMgr.setString('versionNo', versionNo);
    print('版本号: ${AppData.versionNo}');
  }

  ///获取token名
  static String? get tokenName {
    return CacheMgr.getString('tokenName');
  }

  ///设置token名
  static set tokenName(String? name) {
    CacheMgr.setString('tokenName', name!);
  }

  ///获取token值
  static String? get tokenValue {
    return CacheMgr.getString('tokenValue');
  }

  ///获取token值
  static set tokenValue(String? value) {
    CacheMgr.setString('tokenValue', value!);
  }

  ///获取用户手机号
  static String? get phoneNumber {
    return CacheMgr.getString('phoneNumber');
  }

  ///设置用户手机号
  static set phoneNumber(String? value) {
    CacheMgr.setString('phoneNumber', value!);
  }

  ///获取渠道id
  static String? get cid {
    return CacheMgr.getString('cid');
  }

  ///设置渠道id
  static set cid(String? value) {
    CacheMgr.setString('cid', value!);
  }

  ///获取店铺id
  static String? get sid {
    return CacheMgr.getString('sid');
  }

  ///设置店铺id
  static set sid(String? value) {
    CacheMgr.setString('sid', value!);
  }

  ///获取用户uid
  static String? get uid {
    return CacheMgr.getString('uid');
  }

  static set uid(String? value) {
    CacheMgr.setString('uid', value!);
  }

  static String? get mid {
    return CacheMgr.getString('mid');
  }

  static set mid(String? value) {
    CacheMgr.setString('mid', value!);
  }

  static String? get avatar {
    return CacheMgr.getString('avatar');
  }

  static set avatar(String? value) {
    CacheMgr.setString('avatar', value!);
  }

  static String? get nickname {
    return CacheMgr.getString('nickname');
  }

  static set nickname(String? value) {
    CacheMgr.setString('nickname', value!);
  }

  /// 获取是否登录
  static bool get isLogin {
    return CacheMgr.getBool('isLogin') ?? false;
  }

  /// 设置是否登录
  static set isLogin(bool boolValue) {
    CacheMgr.setBool('isLogin', boolValue);
  }

  /// 是否开启个性话推荐
  static bool get isOpnRecommendConfig {
    return CacheMgr.getBool('isOpnRecommendConfig') ?? false;
  }

  /// 设置个性话推荐
  static set isOpnRecommendConfig(bool boolValue) {
    CacheMgr.setBool('isOpnRecommendConfig', boolValue);
  }
}
